package week11;

import java.io.*;
import java.net.*;
import java.util.Scanner;

/**
 * @author The setting sun
 * @version 1.0
 * @title: WorkClient
 * @description: TODO
 * @date 2021/11/17 10:59
 */
public class WorkClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getLocalHost(), 7777);

        DataInputStream dis = new DataInputStream(socket.getInputStream());
        DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
        Scanner s = new Scanner(System.in);
        Boolean isQuit = true;

        while (isQuit) {
            String write = s.next();
            dos.writeUTF(write);

            String read = dis.readUTF();
            if (read != null) {
                System.out.println("收到服务端信息：" + read);
            }

            if (write.equals("拜拜") || read.equals("拜拜")) {
                isQuit = false;
            }
        }

        if (socket != null) {
            socket.close();
        }
    }
}
